import { useEffect } from "react";
const { ipcRenderer } = window.require("electron");
const useIpcRender = (shortCutKeyObj) => {
  useEffect(() => {
    Object.keys(shortCutKeyObj).forEach((c) => {
      ipcRenderer.on(c, shortCutKeyObj[c]);
    });
    return () => {
      Object.keys(shortCutKeyObj).forEach((c) => {
        ipcRenderer.removeListener(c, shortCutKeyObj[c]);
      });
    };
  });
};

export default useIpcRender;
